﻿using DesignMode.BuilderMode.Examples;
using DesignMode.BuilderMode.Examples.Component;
using DesignMode.BuilderMode.Examples.Component.Impl;

namespace DesignMode.BuilderMode
{
    /// <summary>
    /// 黄金自行车建造者 第二种构造模式
    /// </summary>
    public class GoalBikeBuilder : IGoalBikeBuilder
    {
        public IFrame frame { get { return new AlloyFrame(); } }

        public ISeat seat => new DermisSeat();

        public ITire tire => new SolidTire();

        /// <summary>
        /// 建造者模式 
        /// </summary>
        /// <returns></returns>
        public Bike Build()
        {
            Bike bike = new Bike();
            bike.frame = frame;
            bike.seat = seat;
            bike.tire = tire;
            return bike;
        }
    }


    public class GoalBikeCoppyBuilder : IBikeBuilder
    {
        private Bike mBike = new Bike();

        public Bike Build()
        {
            return mBike;
        }

        public IBikeBuilder BuildFrame()
        {
            mBike.frame = new GoalFrame();
            return this;
        }

        public IBikeBuilder BuildSeat()
        {
            mBike.seat = new DermisSeat();

            return this;
        }

        public IBikeBuilder BuildTire()
        {
            mBike.tire = new SolidTire();
            return this;
        }
    }
}
